import { Getter } from 'vuex';
import { StoreModuleType } from "../store";

export interface StateType {
  title: string;
  path?: string;
  permissionsKey?: string;
  icon?: string;
  children?:StateType[];
}

export interface ModuleType extends StoreModuleType<StateType[]> {
  state: StateType[];
  getters: {
    displayMenu: Getter<StateType[], StateType[]>;
  }
}

const initState: StateType[] = [
    {
        title:"资料管理",
        icon:"fab fa-simplybuilt",
        children:[{
            title:"档案管理",
            path:"/case",
        }]
    },
    {
        title:"文件管理",
        icon:"fas fa-file-word",
        children:[{
            title:"模板管理",
            path:"/file/template",
        }]
    },
    {
        title:"团队管理",
        icon:"fas fa-user-friends",
        permissionsKey:"admin",
        children:[{
            title:"角色管理",
            path:"/team/role",
        },
        {
            title:"用户管理",
            path:"/team/user",
        }]
    },
    {
        title:"系统设置",
        permissionsKey:"admin",
        icon:"fas fa-cogs",
        path:"/setting",
    },
];

const StoreModel: ModuleType = {
  namespaced: true,
  name: 'menu',
  state: {
    ...initState
  },
  getters:{
    displayMenu(state){
        
        console.log(state[0])
        return state
    }
  }
}

export default StoreModel;
